2026-01-29T20:44:56Z
Q: How can I tell if my terminal supports TrueColor (24-bit color)?
A: You can run the following command to test if your terminal supports TrueColor:
awk 'BEGIN{
s="/\\/\\/\\/\\/";
for (colnum = 0; colnum<77; colnum++) {
r = 255-(colnum*255/76);
g = (colnum*510/76);
b = (colnum*255/76);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s\033[0m", substr(s,(colnum%4)+1,1);
}
printf "\n";
}'The above script is from:
If your terminal hardware supports TrueColor, you should see a smooth gradient of colors from red to green to blue. If you see a limited number of colors or a blocky gradient, your terminal may not support true color.
You can also check the COLORTERM environment variable by typing:
echo $COLORTERM
truecolorIf the output is “truecolor” or “24bit”, your terminal hardware supports TrueColor. For most situations, this is sufficient to confirm TrueColor support, and further checks are not generally not beneficial or necessary.
Even if your terminal hardware supports TrueColor, your terminfo may not. Keep in mind that the number of colors set in terminfo only affects applications that choose to use it. A terminfo setting of 256 colors does not limit which of the 16M colors an NCurses application can display, but only the number of color pairs that can be displayed simultaneously.
Note: The remainder of this section takes a deep dive into a rabbit hole that most users will not benefit from exploring. If your terminal hardware supports TrueColor, and the COLORTERM variable indicates TrueColor support, you needn’t continue reading.
You can check your terminfo color capabilities by typing:
tput colorsIf the output is 16777216, your terminfo supports TrueColor.
Even if your hardware supports TrueColor, but the above indicators report only 256 colors or less, you can set the TERM variable to a value that supports Truecolor. For example, you can set the TERM variable to “xterm-direct” by adding the following line to your ~/.bashrc or ~/.zshrc file:
export TERM=xterm-directThe caveat is that xterm-direct and other terminfo files may come with limitations. For example, I have found that xterm-direct, lacks the “ccc” (Can-Change-Color) flag. This flag is advisory only for applications that choose to use it.
I use one of::
export TERM=xterm-ghostty
export TERM=xterm-kitty
export TERM=xterm-bwYou can create your own custom terminfo entry using infocmp and tic, but beware. Terminfo is a complex and sometimes arcane system, and not all applications will work properly with custom entries.
Both the Ghostty and Kitty terminfo files set Number of Colors to 256, and that is perfectly understandable considering that:
If you are determined to have more than 256 colors at one time, you can get around this issue by using infocmp to create a custom terminfo entry that specifies higher color capabilities. Here is an example of how to do this, but it is not recommended.
infocmp xterm-256color > xterm-myterm.tiAdd or modify the following lines in xterm-myterm.ti
ccc, colors#0x1000000, pairs#0x10000Once you have finished editing xterm-myterm.ti, compile it using tic:
tic xterm-myterm.tiAnd, set your TERM environment variable to your new terminfo entry:
export TERM=xterm-mytermYou can also refer to this helpful list of terminals and their color support:
Q: I am trying to view a program file in view, but it is displaying ANSI escape codes.
A: No worries. I have run into the same problem. View is not recognizing the ANSI escape codes. Taking a closer look at the file, I can see the “intro” characters repeated, “0x1b[0x1b[”. This happens when the output file of a colorizer or highlighter is processed a second time by a colorizer or highlighter. It tries to put ANSI escape codes around the existing ANSI escape codes, resulting in the “0x1b[0x1b[” sequence, which View can’t interpret.
Out of curiosity, I ran the same file through less, which produced the same results. In the world of pagers, less is the gold-standard, and apparently they chose not to address this issue. Therefore, it seems the best resolution is to avoid double exposure in the first place. Below, I have included a screenshot using less.
kQ: When I try to view a document that contains line-drawing characters, View displays question marks instead of the line-drawing characters. How can I fix this?
A: The file may contain characters above 0x80, which can’t be translated by View’s character translators. If the offending characters CP-437 line drawing characters, you can convert the file to UTF-8 encoding using a tool like ‘iconv’ or ‘recode’. For example, you can use the following command:
iconv -f CP437 -t UTF-8 inputfile.txt -o outputfile.txtThe images below show, before, on the left, and after, on the right, using iconv.
As an interesting note, this also works for “less”, which displays the decimal representation of the CP437 characters. This could be handy if you have been coding since the 1980s and recognize them as CP437 line-drawing characters.
Q: How can I add color to manual pages?
A: Manual pages use ANSI SGR escape sequences to add color.
0x1b[1m bold
0x1b[2m dim
0x1b[3m italic
0x1b[4m underline
0x1b[22m normal intensity (bold/dim off)
0x1b[23m italic off
0x1b[24m underline off
You can use the following sed script to substitute your own colors:
s/\[2m/\[35;1m/g
s/\[3m/\[33;3;1m/g
s/\[4m/\[31;1m/g
s/\[22m/\[22;0m/g
s/\[23m/\[23;0m/g
s/\[24m/\[24;0m/gYou can save this script to a file, or use the one that comes with Menu, (~/menuapp/msrc/man.sed) and then use it like this:
man -Tutf8 bash | sed -f ~/menuapp/msrc/man.sed | viewThis will display the bash manual page with the specified colors in View.